﻿using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Data;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Net.Sockets;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Globalization;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {

        Topic[] topics;
        String[] topicsNumbers = new String[] { "2256069", //ТБВ
                                                "2329855", //КяВВМ
                                                "2715477", //Лост
                                                "2373248", //Lie to me
                                                "2250291", //FF
                                                "2860285", //Великая война
                                                "2748332"};//Крис

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            /*Topic topic = Topic.RequestTopic("2256069");

            this.textBox1.Text = topic.pubDate;

            String time = "Wed, 14 Apr 2010 13:02:00 GMT";
            DateTime dateValue = DateTime.Parse(time);
            dateValue = dateValue.AddHours(4.0d);
            this.textBox1.Text += "\r\n" + dateValue.ToString("R");*/

            this.topics = Topic.RequestTopics(this.topicsNumbers);

            listView1.View = View.Details;
            listView1.LabelEdit = true;
            listView1.FullRowSelect = true;
            listView1.GridLines = true;
            listView1.Sorting = SortOrder.Ascending;

            ListViewItem[] items = new ListViewItem[this.topics.Length];


            for (int i = 0; i < this.topics.Length; i++)
            {

                items[i] = new ListViewItem((i+1).ToString(), 0);
                if (topics[i].update)
                    items[i].Font = new Font(items[i].Font, FontStyle.Bold);
                items[i].Checked = true;
                items[i].SubItems.Add(this.topics[i].title);
                items[i].SubItems.Add(this.topics[i].getDateTime());
            }

            listView1.Columns.Add("№", 22, HorizontalAlignment.Left);
            listView1.Columns.Add("Заголовок", listView1.Width - 22 - 200 - 5, HorizontalAlignment.Left);
            listView1.Columns.Add("Дата обновления", 200, HorizontalAlignment.Left);

            listView1.Items.AddRange(items);

        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //this.textBox1.Text += "asdfasdf" + "\r\n";
        }

    }
}